FROM node:20 AS builder
LABEL authors="Alex"

# 设置工作目录
WORKDIR /app

# ruoyi-ui 复制到镜像中
COPY . .

# 安装依赖并构建项目
RUN npm install
RUN npm run build:prod


# 构建生产环境镜像
FROM nginx:alpine

# 将构建好的静态文件复制到 Nginx 配置的静态文件目录
COPY --from=builder /app/dist /usr/share/nginx/html

# 将配置文件复制到nginx下
COPY ./conf/default.conf /etc/nginx/conf.d/default.conf

# 暴露端口
EXPOSE 80

# 启动 Nginx 服务器
CMD ["nginx", "-g", "daemon off;"]
